package com.bnzjy.srb.base.config;

import feign.Logger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OpenFeignConfig {
    
    /**
     * OpenFeign日志，进行监控和日志输出
     * @return
     */
    @Bean
    Logger.Level feignLoggerLevel(){
        return Logger.Level.FULL;
    }
    
    /**
     * feign 请求头的拦截器
     * @return
     */
//    @Bean("requestInterceptor")
//    public RequestInterceptor requestInterceptor() {
//        return new RequestInterceptor() {
//            @Override
//            public void apply(RequestTemplate template) {
//                // 1、RequestContextHolder 拿到刚进来的这个请求
//                ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//                HttpServletRequest request = attributes.getRequest();  // 老请求
//                // 2、同步请求头数据，Cookie
//                String cookie = request.getHeader("Cookie");
//                // 给新请求同步了老请求的 cookie
//                template.header("Cookie", cookie);
//            }
//        };
//    }
}
